﻿@page "/Archive/Product/ViewIndex"
@page "/Archive/Product/ViewIndex/{Token}"
@using iTeamyou.LTS.UI.Models;
@using iTeamyou.LTS.UI.Shared.Components.Mobile;

<h5 style="margin-top: 1.5rem;">商品查询</h5>
@*<h5 style="margin-top: 1.5rem;">商品扫码查询</h5>
<div style="margin-top: 2rem;">
    <BarcodeReader OnResult="@Scan" VideoWidth="400" VideoHeight="340" AutoStop="true" DefaultInitDeviceIndex="0" AutoStart="true" />
</div>*@
<Table style="margin-top: 1rem;" TItem="Core.Models.Product"
       IsPagination="true" PageItemsSource="@PageItemsSource" IsStriped="true" ShowLineNo="true"
       CustomerSearchModel="@ProductSearchModel" SearchMode="SearchMode.Top" ShowSearchText="true" ShowSearch="true"
       OnDoubleClickRowCallback="@View"
       ShowSkeleton="true" ShowResetButton="true" ShowEmpty="true"
       OnQueryAsync="@OnQueryAsync" IsAutoRefresh="@IsAutoRefresh" AutoRefreshInterval="2000">
    @*SelectedRows="@SelectedProducts" SelectedRowsChanged="@SelectChanged" IsMultipleSelect="true"*@
    <TableColumns>
        <TableColumn @bind-Field="@context.PId" Width="80" Readonly="true" />
        <TableColumn @bind-Field="@context.UPC" Width="80" />
        <TableColumn @bind-Field="@context.Name" Width="200" Readonly="true" />
        <TableColumn @bind-Field="@context.Specification" Width="100" Readonly="true" />
        <TableColumn @bind-Field="@context.Brand" Width="40" Readonly="true" />
        <TableColumn @bind-Field="@context.SectionId" Width="80" Readonly="true" Text="商品分类">
            <Template Context="value">
                <Tag Color="Color.Primary">@ProductService.GetProductDepartment(value.Value).Description</Tag>
            </Template>
        </TableColumn>
        <TableColumn @bind-Field="@context.OriginPlace" Width="40" Readonly="true" />
        <TableColumn @bind-Field="@context.LastModifiedOn" Width="80" Sortable="true" Readonly="true" />
        <TableColumn @bind-Field="@context.LicenseNum" Width="80" Text="证照数">
            <Template Context="value">
                @if (value.Value == null || value.Value == 0)
                {
                    <Tag Color="Color.Dark">共 0 个证照</Tag>
                }
                else
                {
                    <Tag Color="Color.Primary">共 @value.Value 个证照</Tag>
                }
            </Template>
        </TableColumn>
        @*<TableColumn @bind-Field="@context.Id" Text="操作">
            <Template Context="value">
                <Button Text="查看" OnClick="@(() => View(value.Value))" />
            </Template>
        </TableColumn>*@
    </TableColumns>
    <CustomerSearchTemplate>
        @if (context is ProductSearchModel model)
        {
            <ProductMobileSearch @bind-Value="@model" />
        }
    </CustomerSearchTemplate>
</Table>
